<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加文章</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  
    {include file="public/css"}
    {include file="public/js"}
</head>
<body>

<div class=""  style="padding:20px">

   
<form class="layui-form" action="" method="post">
<input type="hidden" name="id" value="{$Request.param.id}">
               <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"> 文章分类</label>           
                {:get_cate('info_category',$info.cid)}
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"> 文章标题</label>
                <div class="layui-input-inline" style="width:500px">
                  <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="" class="layui-input"  value="{$info.title}">
                </div>
                 <div class="layui-form-mid layui-word-aux"><span class="orange">*</span> 必填</div>
              </div>



              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"> 文章内容</label>
                <div class="layui-input-block" style="padding:20px">  

               {form:ueditor name="content" value="htmlspecialchars_decode($info['content'])" /}

                </div>
 
              </div>


             <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;">点击量</label>
                <div class="layui-input-inline" style="width:150px">
                  <input type="text" name="hits" lay-verify="hits" autocomplete="off" placeholder="" class="layui-input" value="{$info.hits}">
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label" style="width:100px;"></label>
                <div class="layui-input-inline">
                   <button class="layui-btn layui-btn-normal"  lay-submit lay-filter="form">确 定</button>
                    <button class="layui-btn layui-btn-primary"  onclick="back()">返 回</button>
                </div>
              </div>


</form>
</div>

<script>
layui.use(['element', 'layer','form','upload'], function(){
   var  element = layui.element, layer = layui.layer,form = layui.form;;upload = layui.upload;
  
  form.on("select(one)",function(data){

    $.post('{:url("api/category/getCategory")}',{"pid":data.value,"type":"infoCate"},function(json){
        if(json.code ==0){
        $(".two").html(json.data);
        $("#two-box").show();
        form.render();
      }else{
          $("#two-box").hide();
          $("#three-box").hide();
       }
    });

  });
  form.on("select(two)",function(data){
    $.post('{:url("api/category/getCategory")}',{"pid":data.value,"type":"infoCate"},function(json){
       if(json.code ==0){
            $(".three").html(json.data);
            $("#three-box").show();
            form.render();
       }else{
           $("#three-box").hide();
       }
    });

  });
 //监听提交
  form.on('submit(form)', function(data){
    $.post("{:url('info/edit')}",$("form").serialize(),function(json){
      if(json.code == 0){
            qilecms.success(json.msg);
            setTimeout(function(){
            qilecms.back();
            },1000);
            }else{
              qilecms.error(json.msg);
            }
    });
    return false;

  });


  //普通图片上传
  var uploadInst = upload.render({
    elem: '#upload_img'
    ,url: '{:url("upload/images")}'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#images').attr('src', result); //图片链接（base64）
       
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code == -1){
           //上传失败
        return layer.msg(res.msg);
      }else if(res.code ==0){
           //上传成功
       $('#thumb').attr('value',res.data);
        return layer.msg(res.msg);
      }
   
    },
    field:"images[]"
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }

});

});

</script>
<script>

</script>
</body>

</html>